package ioperations;

import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList){
        int i = 0;
        Scanner scanner = new Scanner(System.in);
        System.out.println("查找图书......");
        System.out.print("请输入你要查找的书籍名称：");
        String name = scanner.nextLine();
        for (; i < bookList.getUseSize(); i++) {
            if(name.equals(bookList.getBooks(i).getName())){
                System.out.println(bookList.getBooks(i));
                return ;
            }
        }
        if(i == bookList.getUseSize()){
            System.out.println("没有这本书！");
        }
    }
}
